package com.you.pattern.observer.demo2;

public class Student extends Observable {

    private static Student student;

    private String name;



    public String getName() {
        return name;
    }

    private Student() {
    }

    public static Student getInstance() {
        if (student == null) {
            synchronized (Student.class) {
                if (student == null) {
                    student = new Student();
                }
            }
        }
        return student;
    }

    public void publishQuestion(Question question) {
        System.out.println(question.getUserName() + "提交了一个问题。");
        setChange(true);
        notifyObservers(question);
    }
}
